feat(clerk-react,remix,nextjs): Make path the default routing strategy for NextJS and Remix#2338
Conversation
🦋 Changeset detectedLatest commit: 563f1e7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 8 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
a5ca7a4 to
d2d8af4
Compare
|
@octoper I was able to unblock the CI issues, but had to pull work in from |
d2d8af4 to
25ff3f5
Compare
25ff3f5 to
414cbd6
Compare
fdad171 to
0327a81
Compare
| import { errorThrower } from '../errors/errorThrower'; | ||
| import { noPathProvidedError } from '../errors/messages'; | ||
|
|
||
| export function withPathDefaultRouting<T, P extends RoutingOptions>(Component: T, componentName: string): T { |
There was a problem hiding this comment.
@dimkl Shall we move this to the new react/internal subpath export?
| style={{ display: 'flex', flexDirection: 'column', gap: '2rem', justifyContent: 'center', alignItems: 'center' }} | ||
| > | ||
| <OrganizationProfile /> | ||
| <OrganizationProfile path='/organization' /> |
There was a problem hiding this comment.
❓ Will this error on dev time due to missing type?
There was a problem hiding this comment.
This error will be shown when the component is being rendered. This is a runtime error
| UserProfile, | ||
| } from '@clerk/clerk-react'; | ||
|
|
||
| export const UserProfile: typeof BaseUserProfile = withPathDefaultRouting(BaseUserProfile, 'UserProfile'); |
There was a problem hiding this comment.
Good job using a HOC for this, but I feel that the types here should just work - why did you need to use typeof here?
Could it be that the type of the HOC itself needs tweaking so the type can be inferred correctly?
There was a problem hiding this comment.
I started seeing an error at some point after this PR, that the types couldn't not be inferred automatically.
| @@ -37,6 +54,9 @@ export const SignIn = (props: SignInProps) => { | |||
| export const SignUp = (props: SignUpProps) => { | |||
There was a problem hiding this comment.
It seems that you're not using the HOC for the components that are mounted in paths we can infer using the env variables.
I feel like we should align this behavior by either:
- making the Hoc generic enough to support both cases
- supported env variables for all components
Do you want to discuss offline for possible solutions? :)
There was a problem hiding this comment.
Yep I thought about that too, but the path of <SignIn/> and <SignUp/> can be also defined from the Clerk options on the <ClerkProvider/> and I didn't know if we wanted to make the changes to have ENV and options for every component.
cfe4ca0 to
4da9391
Compare
460354b to
0a122e4
Compare
6067887 to
c62c439
Compare
| <OrganizationProfile routing="hash_or_virtual"/> | ||
| <SignIn routing="hash_or_virtual"/> | ||
| <SignUp routing="hash_or_virtual"/> | ||
| ``` No newline at end of file |
There was a problem hiding this comment.
@SokratisVidros , @nikosdouvlis i have also added examples in changeset
c62c439 to
1922a1d
Compare
…useRoutingOptions
This change is applied to show correct component name. Using Component.displayName was causing a `<withClerk(Component)/>` to be shown in error message
1922a1d to
563f1e7
Compare
Description
This PR introduces changes that will make
pathstrategy the default if thepathprop is filled for Next.js and Remix frameworks, previously the routing strategy if there is noroutingorpathprop filled we would fallback tohashrouting strategy.In addition if no
pathprop is filled an error will be thrown.Checklist
npm testruns as expected.npm run buildruns as expected.Type of change
Packages affected
@clerk/backend@clerk/chrome-extension@clerk/clerk-js@clerk/clerk-expo@clerk/fastifygatsby-plugin-clerk@clerk/localizations@clerk/nextjs@clerk/clerk-react@clerk/remix@clerk/clerk-sdk-node@clerk/shared@clerk/themes@clerk/typesbuild/tooling/chore